package com.dfbz.demo01;

import java.util.Random;
import java.util.Scanner;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo02_Random小练习_01_生成随机数 {
    public static void main(String[] args) {

        // 创建一个随机数
        Random random = new Random();

        // 创建一个扫描器
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入随机数的最大值: ");
        int max = scanner.nextInt();

        System.out.println("请输入随机数的个数: ");
        int num = scanner.nextInt();

        for (int i = 0; i <= num; i++) {
            int r = random.nextInt(max);
            System.out.println(r);

            // 销毁内存,运行效率也不高
//            int r = new Random().nextInt(max);
//            System.out.println(r);
        }


    }
}
